﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>销售到货单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
        <a title="条码打印" href="javascript:;" lay-event="print"><i class="layui-icon">&#xe66d;</i></a>
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input class="layui-input" placeholder="开始日期" name="sDate" id="sDate" style="margin-right:15px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束日期" name="eDate" id="eDate" style="margin-right:15px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="m.cCode" placeholder="入库单号" class="layui-input" id="m.cCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="p.cInvStd" placeholder="规格" class="layui-input" id="p.cInvStd">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>

                        </form>
                    </div>

                    <div class="layui-card-body" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>

    function loadData() {
        layui.use('table', function () {

            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
              { field: 'cCode', title: '入库单号', width: 120 }
            , { field: 'dDate', title: '入库日期', width: 100, }
            , { field: 'cWhName', title: '入库仓库', width: 110, }
            , { field: 'cInvCode', title: '存货编码', width: 130 }
            , { field: 'cInvName', title: '存货名称', width: 130 }
            , { field: 'tssx', title: '特殊属性', width: 100 }
            , { field: 'cInvStd', title: '规 格', width: 100 }
            , { field: 'iQuantity', title: '主数量', width: 100 }
            , { field: 'doneMnum', title: '已打印主数量', width: 120 }
            , { field: 'mUnitName', title: '主单位', width: 80 }
            , { field: 'iNum', title: '辅计量数量', width: 100 }
            , { field: 'doneCnum', title: '已打印辅数量', width: 120 }
            , { field: 'cUnitName', title: '辅单位', width: 80 }
            , { field: 'cDefine22', title: '件数', width: 90 }
            , { field: 'cVenName', title: '供方名称', width: 180 }
            , { field: 'right', title: '数据操作', toolbar: '#barDemo', width: 85, fixed: 'right' }
            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
                //循环表数据根据flag状态给行上色
                $.each(res['data'], function (i, j) {
                    if (parseInt(j["doneMnum"]) >= parseInt(j["iQuantity"]) && parseInt(j["doneCnum"]) >= parseInt(j["iNum"])) {
                        TableRowColor('layui-table-main', i, '#A9F5F2');
                    }

                });
            }
                //   , height: $(document).height() - $('#list').offset().top - 20
            , url: "../Bar/GetDataList?dataType=sw&condition=" + conditon
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [20, 35, 50]
            , limit: 20 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event === 'print') {
                    if (parseInt(data.doneMnum) >= parseInt(data.iQuantity) && parseInt(data.doneCnum) >= parseInt(data.iNum)) {
                        layer.msg('不允许超数量打印'); return;
                    }
                    SSO("dhd", JSON.stringify(data));
                } 
            });

        });
    }

    $(function () {
        //获取列表
        loadData();
    })
    layui.use(['laydate'], function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var nowTime = new Date().valueOf();
        var max = null;
        var start = laydate.render({
            elem: '#sDate',
            trigger: 'click',
            type: 'datetime',
            format: 'yyyy/MM/dd',
            max: nowTime,
            btns: ['clear', 'confirm'],
            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date; //最大时间为结束时间的开始值
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#eDate',
            trigger: 'click',
            type: 'datetime',
            max: 4073558400000,
            format: 'yyyy/MM/dd',
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = { 'date': curDate.getDate(), 'month': curDate.getMonth() + 1, 'year': curDate.getFullYear() };
                }
                start.config.max = date;//最小时间为开始时间的最大值
                start.config.max.month = date.month - 1;
            }
        })
    })
</script>